//
//  YHTabBarController.swift
//  WeiBoYH
//
//  Created by yanhui on 2017/1/4.
//  Copyright © 2017年 yanhui. All rights reserved.
//

import UIKit

class YHTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let HMTabBar = YHTabBar()
        
        HMTabBar.custonClosure = {[weak self] in
        }
        
        self.setValue(HMTabBar, forKey: "tabBar")
        
        
        addChildViewControllers()
        
    }
    //添加所有子视图控制器
    func addChildViewControllers(){
        
        addChildViewController(vc: YHHomeController(), imageName: "tabbar_home", title: "首页")
        addChildViewController(vc: YHMessageController(), imageName: "tabbar_message_center", title: "消息")
        addChildViewController(vc: YHDiscoverController(), imageName: "tabbar_discover", title: "发现")
        addChildViewController(vc: YHProfileController(), imageName: "tabbar_profile", title: "我的")
        
        
    }
    
    
    //添加单个视图控制器
    func addChildViewController(vc: UIViewController, imageName: String, title: String){
        
        let navController = YHBaseNavController(rootViewController: vc)
        

        
        vc.navigationItem.title = "新浪微博"
        vc.tabBarItem.title = title
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orange], for: .selected)
        vc.tabBarItem.image = UIImage(named: imageName)
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.withRenderingMode(UIImageRenderingMode.alwaysOriginal)
        vc.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -3)
        
        addChildViewController(navController)
    }
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    

   
}
